package com.hypo.service.impl;

import com.hypo.mapper.EmpMapper;
import com.hypo.mapper.StudentMapper;
import com.hypo.pojo.JobOption;
import com.hypo.pojo.Student;
import com.hypo.pojo.StudentOption;
import com.hypo.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public JobOption getEmpJobData() {
        List<Map<String,Object>> list = empMapper.countEmpJobData();
        List<Object> jobList = list.stream().map(dataMap -> dataMap.get("pos")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("total")).toList();
        return new JobOption(jobList, dataList);
    }

    /**
     * 性别
     */
    @Override
    public List<Map> empGenderData() {
        return empMapper.empGenderData();
    }

    @Override
    public List<Map> studentDegreeData() {
        return studentMapper.studentDegreeData();
    }

    /**
     * 班级人数
     */

    @Override
    public StudentOption studentCountData() {
        List<Map<String, Object>> list = studentMapper.studentCountData();
        List<Object> clazzList = list.stream().map(dataMap -> dataMap.get("clazzList")).collect(Collectors.toList());
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("dataList")).collect(Collectors.toList());
        return new StudentOption(clazzList, dataList);
    }
}
